#include "test_common.hpp"
#include "tools/api.hpp"
#include <thread>
#include <chrono>

void test_timer_basic()
{
    TIMER_BEGIN("test_timer");
    std::this_thread::sleep_for(std::chrono::milliseconds(100));
    TIMER_END(toolsLib::LogLevel::INFO, "test_timer");
    
    ASSERT_TRUE(true);
}

void test_timer_string_message()
{
    TIMER_BEGIN("test_string_timer");
    std::this_thread::sleep_for(std::chrono::milliseconds(50));
    TIMER_END(toolsLib::LogLevel::INFO, "test_string_timer");
    
    ASSERT_TRUE(true);
}

void test_timer_int_message()
{
    TIMER_BEGIN(12345);
    std::this_thread::sleep_for(std::chrono::milliseconds(50));
    TIMER_END(toolsLib::LogLevel::INFO, 12345);
    
    ASSERT_TRUE(true);
}

void test_timer_multiple()
{
    TIMER_BEGIN("timer1");
    std::this_thread::sleep_for(std::chrono::milliseconds(30));
    TIMER_END(toolsLib::LogLevel::INFO, "timer1");
    
    TIMER_BEGIN("timer2");
    std::this_thread::sleep_for(std::chrono::milliseconds(30));
    TIMER_END(toolsLib::LogLevel::INFO, "timer2");
    
    ASSERT_TRUE(true);
}

int main()
{
    auto& runner = test_common::TestRunner::getInstance();
    runner.reset();
    
    std::cout << "=== Running Timer Module Tests ===" << std::endl;
    
    runner.runTest("test_timer_basic", test_timer_basic);
    runner.runTest("test_timer_string_message", test_timer_string_message);
    runner.runTest("test_timer_int_message", test_timer_int_message);
    runner.runTest("test_timer_multiple", test_timer_multiple);
    
    std::cout << "\n=== Test Results ===" << std::endl;
    std::cout << "Total: " << runner.getTotal() << std::endl;
    std::cout << "Passed: " << runner.getPassed() << std::endl;
    std::cout << "Failed: " << runner.getFailed() << std::endl;
    
    return runner.getFailed() == 0 ? 0 : 1;
}

